home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / ANTENNA / YAGIU112 / REFCO.C < prev    next >
C/C++ Source or Header  |  1995-08-07  |  482b  |  26 lines

  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <errno.h>
  4. #include "yagi.h"
  5. extern int errno;
  6. extern double Zo;
  7.  
  8. void reflection_coefficient(struct FCOMPLEX zi, double *magnitude, double *phase)
  9. {
  10.     struct FCOMPLEX zo, rho;
  11.  
  12.     /* reflection coefficient rho = (Zi-Zo)/(Zi+Zo) */
  13.     zo.r=Zo;
  14.     zo.i=0;
  15.     rho=Cdiv(Csub(zi, zo), Cadd(zi,zo));
  16.     *magnitude=Cabs(rho);
  17.     *phase=atan2(rho.i,rho.r);
  18. #ifdef DEBUG
  19.     if(errno)
  20.     {
  21.     fprintf(stderr,"Errno =%d in refco.c \n", errno);
  22.     exit(1);
  23.     }
  24. #endif
  25. }
  26.